#Kiwi Editor is a framework for building WYSIWYG web editors.
#Copyright (C) 2011  Roosevelt de Lima Sardinha

#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.

#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.

#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

#Contact the author at roosevelt1@gmail.com (Roosevelt) 

KiwiServerClient::Application.routes.draw do
  get "pages/sample"

  # Documents  
  resources :documents, :only => [:create, :destroy, :update, :index]
  resources :profiles, :only => [:create, :destroy, :update, :index]
  resources :workspaces, :only => [:create, :destroy, :update, :index]
  resources :eo_types, :only => [:create, :destroy, :index]
  match 'eo_types/:id', :to => 'eo_types#get', :via => :get
  match 'documents/:id', :to => 'documents#get', :via => :get
  match 'profiles/:id', :to => 'profiles#get', :via => :get
  match 'workspaces/:id', :to => 'workspaces#get', :via => :get
  match 'documents/:id/exist', :to=> 'documents#exists?', :via => :get
  match 'profiles/:id/exist', :to=> 'profiles#exists?', :via => :get
  match 'workspaces/:id/exist', :to=> 'workspaces#exists?', :via => :get
  
  # Adding profiles and types associations
  match 'profiles/:id/types', :to => 'assoc_profile_types#create', :via => :post
  match 'profiles/:id/types/:type_id', :to => 'assoc_profile_types#destroy', :via => :delete    
  
  # Adding workspaces and profiles associations
  match 'workspaces/:workspace_id/profiles', :to => 'assoc_workspace_profiles#create', :via => :post
  match 'workspaces/:workspace_id/profiles/:profile_id', :to => 'assoc_workspace_profiles#destroy', :via => :delete
  
  root :to => 'pages#sample'

  namespace :tools do
       resources :images
  end

  # The priority is based upon order of creation:
  # first created -> highest priority.

  # Sample of regular route:
  #   match 'products/:id' => 'catalog#view'
  # Keep in mind you can assign values other than :controller and :action

  # Sample of named route:
  #   match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
  # This route can be invoked with purchase_url(:id => product.id)

  # Sample resource route (maps HTTP verbs to controller actions automatically):
  #   resources :products

  # Sample resource route with options:
  #   resources :products do
  #     member do
  #       get 'short'
  #       post 'toggle'
  #     end
  #
  #     collection do
  #       get 'sold'
  #     end
  #   end

  # Sample resource route with sub-resources:
  #   resources :products do
  #     resources :comments, :sales
  #     resource :seller
  #   end

  # Sample resource route with more complex sub-resources
  #   resources :products do
  #     resources :comments
  #     resources :sales do
  #       get 'recent', :on => :collection
  #     end
  #   end

  # Sample resource route within a namespace:
  #   namespace :admin do
  #     # Directs /admin/products/* to Admin::ProductsController
  #     # (app/controllers/admin/products_controller.rb)
  #     resources :products
  #   end

  # You can have the root of your site routed with "root"
  # just remember to delete public/index.html.
  # root :to => "welcome#index"

  # See how all your routes lay out with "rake routes"

  # This is a legacy wild controller route that's not recommended for RESTful applications.
  # Note: This route will make all actions in every controller accessible via GET requests.
  # match ':controller(/:action(/:id(.:format)))'
end
